<?php
$tg=time();
$tgout=900;
$tgnew=$tg - $tgout;
$conn=mysql_connect("localhost","root","root") or die("can't connect");
mysql_select_db("thoitrang",$conn);
$sql="insert into useronline(tgtmp,ip,local) values('$tg','$REMOTE_ADDR','$PHP_SELF')";
$query=mysql_query($sql);
$sql="delete from useronline where tgtmp < $tgnew";
$query=mysql_query($sql);
$sql="SELECT DISTINCT ip FROM useronline WHERE local='$PHP_SELF'";
$query=mysql_query($sql);
$user = mysql_num_rows($query);
echo "user online :$user";
?>